package com.adt.studioms.web.servlet;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.adt.studioms.StudiomsApplication;

public class ApplicationBootstrap implements ServletContextListener {
    Log log = LogFactory.getLog(ApplicationBootstrap.class);
    
    void startApplication() {
        log.info("_/_/_/_/_/_/_/_/_/_/ Starting Studioms Application... _/_/_/_/_/_/_/_/_/_/");
        
        new StudiomsApplication("springcfg/studioms.application.cfg.xml").start();
        
        log.info("_/_/_/_/_/_/_/_/_/_/ Studioms Application started! _/_/_/_/_/_/_/_/_/_/");
    }
    
    void stopApplication() {
        log.info("_/_/_/_/_/_/_/_/_/_/ Stopping Studioms Application... _/_/_/_/_/_/_/_/_/_/");
        
        StudiomsApplication.instance.stop();
        
        log.info("_/_/_/_/_/_/_/_/_/_/ Studioms Application stopped! _/_/_/_/_/_/_/_/_/_/");
    }
    
    public void contextInitialized(ServletContextEvent event) {
        startApplication();
    }
    
    public void contextDestroyed(ServletContextEvent event) {
        stopApplication();
    }

}
